package com.gitee.es.dynamics.common;

import lombok.Data;

import java.util.List;

@Data
public class PageValues<T> {
    /**
     * 页码
     */
    private Integer page;
    /**
     * 页数
     */
    private Integer limit;

    /**
     * DESC 降序 ASC升序 支持多组
     */
    private List<String> orderTypes;
    /**
     * 排序字段 支持多组 按顺序排列
     */
    private List<String> orderColumns;
    /**
     * 是否查询总条数
     */
    private Boolean isSearchCount=true;

    /**
     * 记录
     */
    private List<T> records;
    /**
     * 总条数
     */
    private Long total;

    private PageValues(Integer page, Integer limit) {
        this.page = page;
        this.limit = limit;
    }

    private PageValues(Integer page, Integer limit, List<String> orderTypes, List<String> orderColumns) {
        this.page = page;
        this.limit = limit;
        this.orderTypes = orderTypes;
        this.orderColumns = orderColumns;
    }

    public static <T> PageValues<T> of(Integer page, Integer limit) {
        return new PageValues<>(page, limit);
    }

    public static <T> PageValues<T> of(Integer page, Integer limit, List<String> orderTypes, List<String> orderColumns) {
        return new PageValues<>(page, limit, orderTypes, orderColumns);
    }
}
